package com.yanqu.road.logic.pb;

import com.yanqu.road.logic.union.UnionWarManger;
import com.yanqu.road.logic.config.GameConfig;
import com.yanqu.road.entity.union.UnionWarDetail;
import com.yanqu.road.entity.activity.unionwar.cross.UnionWarPatronsData;
import com.yanqu.road.pb.unionwar.UnionWarProto;

import java.util.List;

public class UnionWarPb {

    public static UnionWarProto.UnionWarDetailMsg.Builder parseUnionWarDetailMsg(UnionWarDetail unionWarDetail, boolean isWatchBattle) {
        UnionWarProto.UnionWarDetailMsg.Builder msg = UnionWarProto.UnionWarDetailMsg.newBuilder();
        msg.setUnionWarDateStr(GameConfig.UNION_WAR_DATE);
        msg.setIsWatchBattle(isWatchBattle);
        if (null == unionWarDetail) {
            msg.setJoinCount(0);
            return msg;
        }
        msg.setJoinCount(UnionWarManger.getUnionWarJoinUserCount(unionWarDetail));

        List<UnionWarPatronsData> patronsList = unionWarDetail.getPatronsList();

        for (UnionWarPatronsData patronsData : patronsList) {
            UnionWarProto.UnionWarPatronsDataMsg.Builder patronsMsg = UnionWarProto.UnionWarPatronsDataMsg.newBuilder();
            patronsMsg.setUserId(patronsData.getUserId());
//            patronsMsg.setNickName(patronsData.getNickName());
            patronsMsg.setPatronsId(patronsData.getPatronsId());
//            patronsMsg.setAbility(patronsData.getAbility());
//            patronsMsg.setPosition(patronsData.getPosition());
//            patronsMsg.setBookType(patronsData.getBookType());
            patronsMsg.setSkillAddition(patronsData.getSkillAddition());
            patronsMsg.setPatronsLv(patronsData.getPatronsLv());
            patronsMsg.setPatronsStageLv(patronsData.getPatronsStageLv());
            msg.addPatronsData(patronsMsg);
        }
        return msg;
    }
}
